package exhibition.app.nexd.cn.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import org.w3c.dom.Text;

import butterknife.Bind;
import butterknife.OnClick;
import exhibition.app.nexd.cn.R;
import exhibition.app.nexd.cn.adapter.OrderFormAdapter;
import exhibition.app.nexd.cn.presenter.OrderDetailPresenter;
import exhibition.app.nexd.cn.ui.ivew.IOrderDetailActivityView;


/***
 * 订单详情界面
 */
public class OrderFormDetailActivity extends BaseActivity<OrderDetailPresenter> implements IOrderDetailActivityView {
    @Bind(R.id.order_form_lv_list)
    ListView lvOrderForm;

    OrderFormAdapter orderFormAdapter;

    @Bind(android.R.id.empty)
    TextView textEmpty;
    @Bind(R.id.order_form_tv_price)
    TextView tvTotal;

    @Override
    public void initView() {
        getSupportActionBar().hide();
        presenter.calculationOrder();
        orderFormAdapter = new OrderFormAdapter(presenter.getOrderForms(), this);
        lvOrderForm.setAdapter(orderFormAdapter);
        lvOrderForm.setEmptyView(textEmpty);
        orderFormAdapter.notifyDataSetChanged();
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_order_form_detail;
    }

    @Override
    protected void initPresenter() {
        presenter = new OrderDetailPresenter(this, this);
        presenter.init();
    }


    @Override
    public void showToast(String msg) {

    }

    @OnClick(R.id.top_icon_back)
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.top_icon_back:
                Intent intent = new Intent(OrderFormDetailActivity.this, MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();
        }
    }

    @Override
    public void setTotalPrice(double totalPrice) {
        tvTotal.setText("总价：" + String.valueOf(totalPrice));
    }
}
